﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QL_LichCT.Utilities;

namespace QL_LichCT.PresentationLayer
{
    public partial class frmMaim : Form
    {
        public frmMaim()
        {
            InitializeComponent();
        }

        //biến lưu tên nhóm quyền
        public static string tenQuyen;

        #region Hiện Menu theo đối tượng người dùng
       private void Show_Menu(string q)
        {
            switch (q)
            {
                case "AD":
                    menuAdmin.Visible = true;
                    break;
                case "Q2":
                    menuQ2.Visible = true;
                    break;
                case "Q1":
                    menuQ1.Visible = true;
                    break;
            }
        }
        #endregion

        //Điều chỉnh kích thước hình nền theo kích thước Form
        private void frmMaim_Resize(object sender, EventArgs e)
        {
            picNen.Width = this.Width - 14;
            picNen.Height = this.Height - 38;
        }

        //Hiện Form Đăng nhập
        private void picNen_Click(object sender, EventArgs e)
        {
            Form frm1 = new frmLogin();
            frm1.ShowDialog();
            if (Global_Var.quyen != null)
            {
                picNen.Visible = false;

            //    MessageBox.Show(Global_Var.quyen.ToString());
                Show_Menu(Global_Var.quyen.ToString());
                sStp_lbl_Quyen.Text = tenQuyen;
                sStrp_lbl_uID.Text = Global_Var.uID + "   ";
            }
        }

        private void frmMaim_Load(object sender, EventArgs e)
        {

        }

        private void form1_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("FrmXemLichBan"))
                        {
                            Form frm = new FrmXemLichBan();
                            frm.MdiParent = this;
                            frm.Show();
                        }
        }

        private void form2_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("FrmXepLichHop"))
            {
                Form frm = new FrmXepLichHop();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void thoátToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                menuQ2.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }
            
        }
/*
    #region Menu Nhân viên bộ phận Quản lý sản xuất
        private void mStrp_SXU_TrongCa_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmSPTrongCa"))
            {
                Form frm = new frmSPTrongCa();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_SXU_TangCa_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmSPTangCa"))
            {
                Form frm = new frmSPTangCa();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_SXU_Phat_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmPhat"))
            {
                Form frm = new frmPhat();
                frm.MdiParent = this;
                frm.Show();
            }

        }

        private void mStrp_SXU_KQSanXuat_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCSanXuat"))
            {
                Form frm = new frmBCSanXuat();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_SXU_ThgTinCN_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_SXU_DoiMK_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_SXU_thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_SXU.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }
            
        }

        private void mStrp_SXU_TroGiup_Click(object sender, EventArgs e)
        {

        }
        #endregion
   
        #region Menu nhân viên phòng Nhân sự
        private void mStrp_NHS_NghiBH_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmNghiBaoHiem"))
            {
                Form frm = new frmNghiBaoHiem();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHS_NghiKL_Click(object sender, EventArgs e)
        {
            if(!Methods.ckeck_FormOpented("frm_NghiKL"))
            {
                Form frm = new frm_NghiKL();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHS_NgoaiGio_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmLamNgoaiGio"))
            {
                Form frm = new frmLamNgoaiGio();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHS_KQChamCong_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCChamCong"))
            {
                Form frm = new frmBCChamCong();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHS_ThgTinCN_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_NHS_DoiMK_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_NHS_Thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_NHS.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";

            }
            
        }

        private void mStrp_NHS_TroGiup_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region Menu Công nhân
        private void mStrp_CNH_ThgTinCN_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_CNH_BangLuong_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCLuongCN"))
            {
                Form frm = new frmBCLuongCN();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_CNH_KQSanXuat_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCSanXuat"))
            {
                Form frm = new frmBCSanXuat();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_CNH_DoiMK_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_CNH_Thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_CNH.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }

        }

        private void mStrp_CNH_TroGiup_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region Menu Nhân viên Phòng kế toán
        private void mStrp_KTO_NhanVienVP_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCLuongNV"))
            {
                Form frm = new frmBCLuongNV();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_KTO_CongNhan_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCLuongCN"))
            {
                Form frm = new frmBCLuongCN();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_KTO_ThgTinCN_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_KTO_DoiMK_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_KTO_Thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_KTO.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }

        }

        private void mStrp_KTO_TroGiup_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region Menu Nhân viên văn phòng
        private void mStrp_NHV_ThgTinCN_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_NHV_BangLuong_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCLuongNV"))
            {
                Form frm = new frmBCLuongNV();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHV_KQChamCong_Click(object sender, EventArgs e)
        {
            if (!Methods.ckeck_FormOpented("frmBCChamCong"))
            {
                Form frm = new frmBCChamCong();
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mStrp_NHV_DoiMK_Click(object sender, EventArgs e)
        {

        }

        private void mStrp_NHV_Thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_NHV.Visible = false;
                picNen.Visible = true;
               
                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }

        }

        private void mStrp_NHV_TroGiup_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region Menu Nhân viên quản trị CSDL
        private void mStrp_ADM_Thoat_Click(object sender, EventArgs e)
        {
            string mesage = "Bạn muốn thoát khỏi chương trình?";
            if (MessageBox.Show(mesage, "Đăng xuất", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                frmMainULL.Thoat();
                Methods.closeChildForm();
                mStrp_ADM.Visible = false;
                picNen.Visible = true;

                sStp_lbl_Quyen.Text = "...";
                sStrp_lbl_uID.Text = "...";
            }

        }

        private void mStrp_ADM_TroGiup_Click(object sender, EventArgs e)
        {
            
        }
        #endregion

        private void mStrp_SXU_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }
*/
    }     
}
